package com.xmkj.bearuser.sort;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.common.cons.Constans;
import com.common.retrofit.bean.SecondSortBean;
import com.common.utils.EmptyUtils;
import com.common.utils.SPUtils;
import com.common.widget.recyclerview.refresh.adapter.CommonAdapter;
import com.common.widget.recyclerview.refresh.adapter.ViewHolder;
import com.xmkj.bearuser.R;
import com.xmkj.bearuser.count.LoginActivtiy;
import com.xmkj.bearuser.pk.GoodsDetailsActivity;

import java.util.List;

/**
 * Create by leo
 * 创建日期：2018/7/3
 * 描述：
 */

public class SecondSortAdapter extends CommonAdapter<SecondSortBean.CategoryTwoEntity> {
    public SecondSortAdapter(Context context, List<SecondSortBean.CategoryTwoEntity> data) {
        super(context, data);
    }

    @Override
    protected void convert(ViewHolder holder, final SecondSortBean.CategoryTwoEntity item, int position) {
        holder.setText(R.id.tv_name,item.c_name);
        holder.setImageStr(R.id.iv_img,item.c_pic);
        holder.getParentView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {


                if(EmptyUtils.isEmpty(SPUtils.getShareString(Constans.HASHID))){
                    Intent intent = new Intent(mContext, LoginActivtiy.class);
                    mContext.startActivity(intent);
                }else {
                    Intent intent = new Intent(mContext, ThreeListActivity.class);
                    intent.putExtra(ThreeListActivity.BEAN,item);
                    mContext.startActivity(intent);

                }
            }
        });
    }

    @Override
    protected int getItemViewLayoutId(int position, SecondSortBean.CategoryTwoEntity item) {
        return R.layout.item_sort;
    }
}
